package org.link.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * 
 * project_name:hibernate_annotation
 * package_name:org.link.bean
 * file_name:Student.java
 * @author Link
 * create_date:2015年12月15日 上午9:40:33
 * modified_date:
 * description:学生实体类
 *
 */

@Entity//此注解也来自javax包
@Table(name="t_student")//注意:此table来自javax.persistence这个包而不是hibernate包
public class Student {

	@Id//逻辑主建
	@GenericGenerator(name="systemUUID",strategy="uuid")
	@GeneratedValue(generator="systemUUID")
	@Column(name = "sid", insertable = true, updatable = true, nullable = false,length=36)
	private String sid;
	@Column(name="sname",length=30)//此为对应数据库的字段名
	private String sname;
	@Column(name="ssex",length=20)
	private String ssex;
	@ManyToOne(fetch=FetchType.LAZY)//延迟加载,指定多对一的关系
	@JoinColumn(name="cid")//指定外键所关联的表
	private ClassRoom classRoom;
	
	public Student() {
		super();
	}

	public Student(String sname, String ssex, ClassRoom classRoom) {
		super();
		this.sname = sname;
		this.ssex = ssex;
		this.classRoom = classRoom;
	}

	public Student(String sid, String sname, String ssex, ClassRoom classRoom) {
		super();
		this.sid = sid;
		this.sname = sname;
		this.ssex = ssex;
		this.classRoom = classRoom;
	}

	

	public String getSid() {
		return sid;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}

	public String getSname() {
		return sname;
	}

	public void setSname(String sname) {
		this.sname = sname;
	}

	public String getSsex() {
		return ssex;
	}

	public void setSsex(String ssex) {
		this.ssex = ssex;
	}

	public ClassRoom getClassRoom() {
		return classRoom;
	}

	public void setClassRoom(ClassRoom classRoom) {
		this.classRoom = classRoom;
	}

	@Override
	public String toString() {
		return "Student [sid=" + sid + ", sname=" + sname + ", ssex=" + ssex + ", classRoom=" + classRoom + "]";
	}
	
	
	
}
